function frameUrl(info, tab) {
    var url = info.frameUrl;
    if (info.frameUrl == undefined){
        url = tab.url;
    }
    chrome.tabs.sendRequest(tab.id, { url: url}, function(response) {});
}

function baidu(info, tab) {
    chrome.tabs.create({ url: "http://www.baidu.com/s?wd="+info.selectionText, selected: true}, function(response) {});
}

function youdao(info, tab) {
    chrome.tabs.create({ url: "http://dict.youdao.com/search?q="+info.selectionText, selected: true}, function(response) {});
}

var selection = chrome.contextMenus.create({"title": "百度一下","contexts":["selection"],"onclick":baidu});
var selection = chrome.contextMenus.create({"title": "有道翻译","contexts":["selection"],"onclick":youdao});
var selection = chrome.contextMenus.create({"title": "当前URL","contexts":["all"],"onclick":frameUrl});
